﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Datorgrafik_lab2.Helpers {
    class QuadHelper {

        private float maxRow;
        private float maxCol;
        private float quadRadius;
        private float quadDiameter;
        private float colDist;
        private float rowDist;

        public QuadHelper(float maxRows, float maxColumns, float quadradius) {
            this.maxRow = maxRows;
            this.maxCol = maxColumns;
            this.quadRadius = quadradius;
            this.quadDiameter = this.quadRadius * 2;

            this.colDist = this.quadDiameter / (this.maxCol * this.quadDiameter);
            this.rowDist = this.quadDiameter / (this.maxRow * this.quadDiameter);
        }


        public QuadTexturePositions getTexturePoints(float row, float col) {

            float y = row / this.maxRow;
            float x = col / this.maxCol;

            return new QuadTexturePositions{
                topLeft = new Vector2(x, y),
                bottomRight = new Vector2(x + this.colDist, y + this.rowDist),
                bottomLeft = new Vector2(x, y + this.rowDist),
                topRight = new Vector2(x + this.colDist, y)
            };
        }

        public QuadVerticePositions getVerticePoints(Vector3 position) {
            return new QuadVerticePositions {
                topLeft = position + new Vector3(this.quadRadius, 0, this.quadRadius),
                bottomRight = position + new Vector3(-this.quadRadius, 0, -this.quadRadius),
                bottomLeft = position + new Vector3(this.quadRadius, 0, -this.quadRadius),
                topRight = position + new Vector3(-this.quadRadius, 0, this.quadRadius)
            };
        }
    }
}
